#!/bin/bash

#git commit
BRANCH=`git log |head -n 1 |awk '{print $2}'` 
#docker image仓库地址
REGISRTY="904351299"
#镜像名称
IMAGE_NAME="${REGISRTY}/${JOB_NAME}:${BRANCH}"

docker build -t ${IMAGE_NAME} .
docker push ${IMAGE_NAME}


/usr/bin/sed -i "s%JOB_NAME%${JOB_NAME}%g" deploy.yaml

/usr/bin/sed -i "s%IMAGE_NAME%${IMAGE_NAME}%g" deploy.yaml

sudo /usr/local/bin/kubectl apply -f deploy.yaml